Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema update #110

Closed
wants to merge 1 commit into from
Closed

Schema update #110

wants to merge 1 commit into from

Conversation

ariga-bot
Copy link
Collaborator

Renamed 'email' column to 'email_address' in the 'users' table to demonstrate a backward-incompatible change.

Copy link
Contributor

atlas migrate lint on dirs/ecommerce/migrations

Status Step Result
1 new migration file detected 20241112131146.sql
ERD and visual diff generated View Visualization
Analyze 20241112131146.sql
2 reports were found in analysis
Destructive changes detected
Dropping non-virtual column "email" (DS103)
Data dependent changes detected
Adding a non-nullable "varchar" column "email_address" on table "users" without a default value implicitly sets existing rows with "" (MY101)
Read the full linting report on Atlas Cloud

Comment on lines +1 to +2
-- Modify "users" table
ALTER TABLE `users` DROP CHECK `users_chk_1`, ADD CONSTRAINT `users_chk_1` CHECK (regexp_like(`email_address`,_utf8mb4'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}$')), DROP COLUMN `email`, ADD COLUMN `email_address` varchar(255) NOT NULL, ADD UNIQUE INDEX `email_address` (`email_address`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

destructive changes detected
Dropping non-virtual column "email" DS103

Add a pre-migration check to ensure column "email" is NULL before dropping it

Suggested change
-- Modify "users" table
ALTER TABLE `users` DROP CHECK `users_chk_1`, ADD CONSTRAINT `users_chk_1` CHECK (regexp_like(`email_address`,_utf8mb4'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}$')), DROP COLUMN `email`, ADD COLUMN `email_address` varchar(255) NOT NULL, ADD UNIQUE INDEX `email_address` (`email_address`);
-- atlas:txtar
-- checks/destructive.sql --
-- atlas:assert DS103
SELECT NOT EXISTS (SELECT 1 FROM `users` WHERE `email` IS NOT NULL) AS `is_empty`;
-- migration.sql --
-- Modify "users" table
ALTER TABLE `users` DROP CHECK `users_chk_1`, ADD CONSTRAINT `users_chk_1` CHECK (regexp_like(`email_address`,_utf8mb4'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}$')), DROP COLUMN `email`, ADD COLUMN `email_address` varchar(255) NOT NULL, ADD UNIQUE INDEX `email_address` (`email_address`);

Ensure to run atlas migrate hash --dir "file://dirs/ecommerce/migrations" after applying the suggested changes.

@giautm giautm closed this Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants